Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

react_refresh: Don't visit arrow function nodes #37

Merged
merged 1 commit into from
Aug 29, 2024

Conversation

martinhath
Copy link
Contributor

Since atoms created in a function context are new atoms, there's nothing in the arrow function sub-tree that we should transform. The default behavior seems to be to visit everything, whereas an empty impl stops the walk.

Another driveby fix: store previous top_level in visit_mut_stmts instead of always resetting it to true. I don't have a failing test for this (so it might be fine), but it's a pattern that's explicitly called out in the docs 0.

Fixes #36

Since atoms created in a function context are new atoms, there's
nothing in the arrow function sub-tree that we should transform. The
default behavior seems to be to visit everything, whereas an empty impl
stops the walk.

Another driveby fix: store previous `top_level` in `visit_mut_stmts`
instead of always resetting it to `true`.  I don't have a failing test
for this (so it might be fine), but it's a pattern that's explicitly
called out in the docs [0].

[0]: https://swc.rs/docs/plugin/ecmascript/cheatsheet#make-your-handlers-stateless

Fixes pmndrs#36
@martinhath
Copy link
Contributor Author

As it turns out, this also fixes #34

Copy link

@meyer meyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m not a code owner so this review doesn’t mean much but thanks for fixing this issue, it’s caused some truly baffling bugs.

@Thisen Thisen merged commit 2bde4e9 into pmndrs:main Aug 29, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Higher order functions are changed by react_refresh
3 participants